//============================================================================
/// \file   DockComponentsFactory.cpp
/// \author Uwe Kindler
/// \date   10.02.2020
/// \brief  Implementation of DockComponentsFactory
//============================================================================

//============================================================================
//                                   INCLUDES
//============================================================================
#include <AutoHideTab.h>
#include "DockComponentsFactory.h"

#include <memory>

#include "DockWidgetTab.h"
#include "DockAreaTabBar.h"
#include "DockAreaTitleBar.h"
#include "DockWidget.h"
#include "DockAreaWidget.h"

namespace ads {
    // 创建默认工厂实例
    static std::unique_ptr<CDockComponentsFactory> DefaultFactory(new CDockComponentsFactory());

    // 创建给定停靠窗口的停靠窗口选项卡
    CDockWidgetTab* CDockComponentsFactory::createDockWidgetTab(CDockWidget* DockWidget) const {
        return new CDockWidgetTab(DockWidget);
    }

    // 创建给定停靠窗口的自动隐藏侧边选项卡
    CAutoHideTab* CDockComponentsFactory::createDockWidgetSideTab(CDockWidget* DockWidget) const {
        return new CAutoHideTab(DockWidget);
    }

    // 创建给定停靠区窗口的停靠区选项卡栏
    CDockAreaTabBar* CDockComponentsFactory::createDockAreaTabBar(CDockAreaWidget* DockArea) const {
        return new CDockAreaTabBar(DockArea);
    }

    // 创建给定停靠区窗口的停靠区标题栏
    CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidget* DockArea) const {
        return new CDockAreaTitleBar(DockArea);
    }

    // 获取默认工厂实例
    const CDockComponentsFactory* CDockComponentsFactory::factory() {
        return DefaultFactory.get();
    }

    // 设置默认工厂实例
    void CDockComponentsFactory::setFactory(CDockComponentsFactory* Factory) {
        DefaultFactory.reset(Factory);
    }

    // 将默认工厂实例重置为新实例
    void CDockComponentsFactory::resetDefaultFactory() {
        DefaultFactory.reset(new CDockComponentsFactory());
    }
} // namespace ads

//---------------------------------------------------------------------------
// EOF DockComponentsFactory.cpp
